require("lsqlite3")
local db = sqlite3.open("items.db")

local q = [[
SELECT
	cd.item_id itemid, cd.dropRate rate
FROM
	creatureDrops cd
JOIN
	creatures c
ON
	c.id = cd.creature_id
WHERE
	drop_id = 1
AND
	heroic = %d
AND
	c.name = "%s"
ORDER BY
	rate DESC, itemid ASC
]]

local lt = {}
if arg[1] then
	for itemid, rate in db:urows(q:format(arg[2] == "heroic" and 1 or 0, arg[1])) do
		lt[#lt + 1] = itemid..":"..rate
	end
end
print(table.concat(lt, ","))
